<div class="add-number">
    <div class="number-list">
        <label>联系人：</label>
        <input type="text" id="userName">
    </div>
    <div class="number-list">
        <label>联系号码：</label>
        <input type="number" id="number">
    </div>
    <div class="add-number-btn">
        <button id="addSaveBtn">保 存</button>
        <button id="addCancel">取 消</button>
    </div>
</div>
<script>
    $(".add-number-btn #addSaveBtn").click(function () {
        var code = $("#modal_add_number").data('code');
        var div = '#editmsg' + code;
        var userName = $("#userName").val();
        var number = $("#number").val();
        if (!userName || !number) {
            alert('输入框不得为空');
            return;
        }
        $(div).prepend(`<div class="editmsg-list">
            <input type="text" class="username" value="${userName}">
            <input type="number" class="phone" value="${number}">
            <i id="removeBtn">×</i></div>`);
        $("#modal_add_number").remove();
        $(".add_number").remove();
    })
    $(".add-number-btn #addCancel").click(function () {
        $("#modal_add_number").remove();
        $(".add_number").remove();
    })
</script>